home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_316
/
iff2c
/
src
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
3KB
|
110 lines
/* */
/* Iff2C - Converts an Iff ILBM file to C source */
/* */
/* Last updates: */
/* v0.30, 89.0512, fixed minor output bug, -ghg- */
/* v0.29, 89.0501, plane pick option now works, -ghg- */
/* v0.28, 89.0430, -lsdh options added, jm Forgeas */
/* v0.27, 88.1113, original coding by Gauthier Groult */
/* */
#include <stdio.h>
#include <exec/types.h>
#include <graphics/gfx.h>
#include <libraries/dos.h>
#include <iff/ilbm.h>
#include <iff/readpict.h>
#include <iff/remalloc.h>
#include "iff2c.h"
struct GfxBase *GfxBase;
VOID
main(argc, argv)
UBYTE argc, **argv;
{
UBYTE arg=1,
flags = PRINT_COMMENTS | PRINT_IMAGE | COMPUTE_ONOFF |
STATIC_DATA | PRINT_DATA | LATTICE_CHIP;
LONG file;
IFFP iffp = NO_FILE;
ILBMFrame iFrame;
struct BitMap bitmap;
if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))) exit(1);
if (argc==1)
{
fputs("Usage: Iff2C [-cidpslh] <file> [<file>...]\n", stderr);
fputs(" -c: switches comment output, default on\n", stderr);
fputs(" -i: switches image structure output, default on\n", stderr);
fputs(" -d: switches data words output, default on\n", stderr);
fputs(" -p: plane on/off computation, default on\n", stderr);
fputs(" -s: switches 'static' image data, default on\n", stderr);
fputs(" -l: switches Lattice keyword 'chip', default on\n", stderr);
fputs(" -h: header and trailer words (sprite), default off\n", stderr);
fputs("Iff2C v0.30, by Gauthier Groult & Jm Forgeas, 89.0512, pd\n", stderr);
goto CLEANUP;
}
while (arg<argc)
{
switch(argv[arg][0])
{
case '-':
if (argc==2)
{
fputs("Iff2c: input file name not specified\n", stderr);
goto CLEANUP;
}
switch(argv[arg][1])
{
case 'c': flags &= ~PRINT_COMMENTS; break;
case 'i': flags &= ~PRINT_IMAGE; break;
case 'd': flags &= ~PRINT_DATA; break;
case 'p': flags &= ~COMPUTE_ONOFF; break;
case 's': flags ^= STATIC_DATA; break;
case 'h': flags ^= SPRITE_HEADER; break;
case 'l': flags ^= LATTICE_CHIP; break;
default:
fputs("Iff2c: invalid arguments, try Iff2c for help\n", stderr);
goto CLEANUP;
}
break;
default:
if (file = Open(argv[arg], MODE_OLDFILE))
{
iffp = ReadPicture(file, &bitmap, &iFrame, ChipAlloc);
Close(file);
}
else
{
fprintf(stderr, "Iff2c: wrong file name %s\n", argv[arg]);
goto CLEANUP;
}
if (iffp != IFF_DONE)
{
fprintf(stderr, "Iff2c: wrong file format %s\n", argv[arg]);
goto CLEANUP;
}
BMap2C( stdout, argv[arg], bitmap.Planes[0],
iFrame.bmHdr.x, iFrame.bmHdr.y,
iFrame.bmHdr.w, iFrame.bmHdr.h,
bitmap.Depth, flags );
if (bitmap.Planes[0]) RemFree(bitmap.Planes[0]);
break;
}
arg++;
}
CLEANUP:
CloseLibrary(GfxBase);
exit(0);
}